
//注册接口
const isExistUser = params => request("../php/isExistUser.php", params, "post");
const isExistPhone = params => request("../php/isExistPhone.php", params, "post");
const isExistEmail = params => request("../php/isExistEmail.php", params, "post");
const register = params => request("../php/register.php", params, "post");

//登录接口
const login = params => request("../php/login.php", params, "post");

//商品列表接口
const searchGoodsAllOrderLimit = params => request("../php/searchGoodsAllOrderLimit.php", params);

//商品详情页接口
const searchGoodsDetails = params => request("../php/searchGoodsDetails.php", params);

//购物车
const addCart = params => request("../php/addCart.php", params, "post");
const searchCart = params => request("../php/searchCart.php", params);
const deleteCart = params => request("../php/deleteCart.php", params);
const updateCart = params => request("../php/updateCart.php", params, "post");

//ajax配合Promise二次封装
function request(url, params = "", type = "get") {
    return new Promise(function (resolve) {
        $.ajax({
            type,
            data: { ...params },
            url,
            dataType: "json",
            success(result) {
                resolve(result)
            }
        })
    });
}

